package com.myjob.controller;

import com.myjob.utils.UtilValidate;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Objects;

/**
 * @author Chen Yuan
 * @create 2021-01-27  17:03
 */
@Controller
@Slf4j
@RequestMapping("/oa/jobs")
public class JobController {

	@GetMapping("/bookmarksPage")
	public String bookmarksPage(){
		return "/common/jobs/bookmarks";
	}

	@GetMapping("/CandidateDetailsPage/{userId}/{CorHId}/{huntingId}")
	public String candidateDetailsPage(@PathVariable("userId") String userId,
	                                   @PathVariable("CorHId") String CorHId,
	                                   @PathVariable("huntingId") String huntingId,
	                                   Model model){
		model.addAttribute("userId", userId);
		model.addAttribute("CorHId", CorHId);
		model.addAttribute("huntingId", huntingId);
		return "/common/jobs/candidateDetails";
	}

	@GetMapping("/CandidatesListingPage")
	public String candidatesListingPage(){
		return "/common/jobs/candidatesListing";
	}

	@GetMapping("/candidateStatus")
	public String candidateStatusPage(){
		return "/common/jobs/candidateStatus";
	}

	@GetMapping("/huntingStatusPage")
	public String huntingStatusPage(){
		return "/common/jobs/huntingStatus";
	}

	@GetMapping("/jobApprovalPage")
	public String jobApprovalPage(){
		return "/common/jobs/jobApproval";
	}

	@GetMapping("/jobDetails/{jobId}/{companyId}")
	public String jobDetailsPage(@PathVariable("jobId") String jobId,
								 @PathVariable("companyId") String companyId,
								 Model model){
		model.addAttribute("jobId", jobId);
		model.addAttribute("companyId", companyId);
		return "/common/jobs/jobDetails";
	}

	@GetMapping("/joblisting/{searchValue}")
	public String jobListingPage(@PathVariable("searchValue") String searchValue,
	                             Model model){
		if (UtilValidate.isNotEmpty(searchValue) &&
				!Objects.equals(searchValue, "-")) {
			model.addAttribute("searchValue", searchValue);
		}
		return "/common/jobs/jobListing";
	}

	@GetMapping("/jobStatusManagementPage")
	public String jobStatusManagementPage(){
		return "/common/jobs/jobStatusManagement";
	}

	@GetMapping("/postJobPage")
	public String postJobPage(){
		return "/common/jobs/postJob";
	}

	@GetMapping("/profilePage")
	public String profilePage() {
		return "/common/jobs/profile";
	}
}
